import request from '@/utils/request'
import MODULE from '@/utils/module'

export function getList(data, currentPage, pageSize) {
    return request({
        url: MODULE.MODULE.device + '/Device/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        // url:  "http://127.0.0.1:8765"+MODULE.MODULE.device + '/Device/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        method: 'post',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
            data = JSON.stringify(data)
            return data
        }],
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function doDelete(id) {
    return request({
        url: MODULE.MODULE.device + '/Device/remove',
        method: 'delete',
        params: { id }
    })
}

// 编辑
export function doEdit(data) {
    return request({
        url:MODULE.MODULE.device +  '/Device/edit',
        //url:"http://127.0.0.1:8765"+ MODULE.MODULE.device +  '/Device/edit',
        method: 'PATCH',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
                data = JSON.stringify(data)
                return data
            }],
        headers: {
        'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}


// 查询设备类型
export function queryDeviceList(params) {
  return request({
    url:  MODULE.MODULE.deviceType + '/DeviceType/queryDeviceTypeByOrgan',
    //url:  "http://127.0.0.1:8765"+MODULE.MODULE.deviceType + '/DeviceType/queryDeviceTypeByOrgan',
    method: 'POST',
    params: params

  })
}

export function querySharedList(data, currentPage, pageSize) {
    return request({
        url:  MODULE.MODULE.deviceFlowSharedRevenue + '/DeviceFlowSharedRevenue/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        //url:  "http://127.0.0.1:8765"+MODULE.MODULE.deviceFlowSharedRevenue + '/DeviceFlowSharedRevenue/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        method: 'post',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
            data = JSON.stringify(data)
            return data
        }],
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

// 编辑分润信息
export function doEditShared(data) {
    return request({
        url: MODULE.MODULE.deviceFlowSharedRevenue +  '/DeviceFlowSharedRevenue/editShared',
        //url: "http://127.0.0.1:8765"+MODULE.MODULE.deviceFlowSharedRevenue +  '/DeviceFlowSharedRevenue/editShared',
        method: 'POST',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
                data = JSON.stringify(data)
                return data
            }],
        headers: {
        'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}



// 批量修改
export function batchEdit(data) {
    return request({
        url:MODULE.MODULE.device +  '/Device/batchEdit',
        //url:"http://127.0.0.1:8765"+ MODULE.MODULE.device +  '/Device/batchEdit',
        method: 'PATCH',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
                data = JSON.stringify(data)
                return data
            }],
        headers: {
        'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}


//商户列表
export function getMerchantList(data, currentPage, pageSize) {
    return request({
        url: MODULE.MODULE.merchant +'/Merchant/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        //url: "http://127.0.0.1:8765"+ MODULE.MODULE.merchant +'/Merchant/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        method: 'post',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
            data = JSON.stringify(data)
            return data
        }],
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}






export function bindMerchant(params, data) {
  return request({
    url: MODULE.MODULE.deviceMerchant +  '/DeviceMerchant/bindDeviceMerchant',
   // url:"http://127.0.0.1:8765"+ MODULE.MODULE.deviceMerchant +  '/DeviceMerchant/bindDeviceMerchant',
    method: 'POST',
    params: params,
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


//查询设备货道信息

export function queryAllDeviceAisleBindSituation(data) {
    return request({
        url:  MODULE.MODULE.deviceAisle + '/DeviceAisle/queryAllDeviceAisleBindSituation',
        method: 'post',
        params: {},
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
            data = JSON.stringify(data)
            return data
        }],
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}


//绑定设备货道商户
export function bindDeviceAisleMerchant(params,data) {
    return request({
        //url: MODULE.MODULE.deviceAisle + '/DeviceAisle/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
        url:  MODULE.MODULE.deviceAisleMerchant + '/DeviceAisleMerchant/bindDeviceAisleMerchant',
        method: 'post',
        params: params,
        data: data,
        transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
            data = JSON.stringify(data)
            return data
        }],
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}


